<template>
  <div id="">
    <nav-bar>
      <div slot="left" class="back" @click="$router.back()">
        <img src="~assets/img/common/back.svg" alt="">
      </div>
      <div class="title" slot="center">
        <div v-for="(title, index) in detailTitles" :key="title" class="title-item"
             @click="titleClick(index)"
             :class="{active: index === currentIndex}">
          {{title}}
        </div>
      </div>
    </nav-bar>
  </div>
</template>
<script>
import {detailTitles} from 'common/const'

import NavBar from 'components/common/navbar/NavBar'

export default {
  name: "DetailNavBar",
  data: () => ({
    detailTitles: detailTitles,
    currentIndex: 0
  }),
  components: {
    NavBar
  },
  methods: {
    titleClick(index) {
      this.currentIndex = index;
      this.$emit('titleClick', index);
    }
  }
}
</script>
<style scoped>
.title {
  display: flex;
  font-size: 13px;
}

.title-item {
  flex: 1;
}

.active {
  color: var(--color-high-text);
}

.back img {
  margin-top: 10px;
}
</style>
